package com.arunsawad.ilertu.common;

import com.arunsawad.ilertu.R;

import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.widget.ImageView;

public class LoadImageTask extends AsyncTask<ImageView, Void, Bitmap> {
	ImageView imageView = null;

	@Override
	protected Bitmap doInBackground(ImageView... imageViews) {
		// params[0]: ImageView
		this.imageView = imageViews[0];
		return Utils.getBitmapFromURL((String) imageView.getTag());
	}

	protected void onPreExecute() {

	}

	protected void onPostExecute(Bitmap result) {
		if (result != null) {
			imageView.setImageBitmap(result);
		} else {
			imageView.setImageResource(R.drawable.noimg_128);
		}
	}
}